<template>
	<view class="search">
		<!-- 推荐 开始 -->
		<view class="recommend">
			<view class="recommend-head">
				<text>您可能会喜欢</text>
				<view class="refresh animate__animated" hover-class="animate__wobble">
					<uni-icons
						type="refreshempty"
						size="30rpx"
						style="padding-right: 10rpx; color: #9f9fa3;"
					></uni-icons>
					换一换
				</view>
			</view>
			<!-- 纵向布局 -->
			<template v-if="y_axis">
				<view class="recommend-body">
					<view class="recommend-body-item" v-for="(item, i) in recommendData" :key="i">
						<image class="img" :src="item.imgUrl" mode="aspectFill"></image>
						<view class="userinfo">
							<!-- 头像 -->
							<image :src="item.headPortrait" mode=""></image>
							<view class="data">
								<!-- 昵称 -->
								<text class="nickname">{{ item.username }}</text>
								<!-- 活跃时间 -->
								<text class="time">{{ item.date }}</text>
							</view>
						</view>
					</view>
				</view>
			</template>
			<!-- 横向布局 -->
			<template v-else>
				<scroll-view scroll-x>
					<view class="recommend-body x-w">
						<view
							class="recommend-body-item"
							v-for="(item, i) in recommendData"
							:key="i"
						>
							<image class="img" :src="item.imgUrl" mode="aspectFill"></image>
							<view class="userinfo">
								<!-- 头像 -->
								<image :src="item.headPortrait" mode=""></image>
								<view class="data">
									<!-- 昵称 -->
									<text class="nickname">{{ item.username }}</text>
									<!-- 活跃时间 -->
									<text class="time">{{ item.date }}</text>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</template>
		</view>
		<!-- 推荐 结束 -->
	</view>
</template>

<script>
export default {
	name: 'my-recommend',
	props: {
		recommendData: {
			type: Array,
			default: () => []
		},

		// 是否纵向布局
		y_axis: {
			type: Boolean,
			default: true
		}
	},
	data() {
		return {}
	}
}
</script>

<style lang="less">
.x-w {
	width: 1350rpx;
}
.search {
	width: 660rpx;
	margin: 0 auto;
	.recommend {
		margin-top: 60rpx;
		.recommend-head {
			display: flex;
			justify-content: space-between;
			align-items: center;
			text {
				font-size: 30rpx;
				font-weight: 600;
			}
			.refresh {
				font-size: 30rpx;
				color: #9f9fa3;
			}
		}
		.recommend-body {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			margin-top: 30rpx;
			.recommend-body-item {
				position: relative;
				width: 318rpx;
				height: 440rpx;
				border-radius: 25rpx;
				margin-bottom: 20rpx;
				.img {
					width: 100%;
					height: 100%;
					border-radius: 25rpx;
				}
				.userinfo {
					position: absolute;
					display: flex;
					align-items: center;
					top: 77%;
					width: 318rpx;
					height: 100rpx;
					border-radius: 0 0 25rpx 25rpx;
					background-image: linear-gradient(0deg, #000000, transparent);
					image {
						width: 70rpx;
						height: 70rpx;
						margin: 0 20rpx;
						border-radius: 50%;
						box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
						border: 2rpx solid #ffaa00;
					}
					.data {
						display: flex;
						flex-direction: column;
						.nickname {
							font-size: 28rpx;
							font-weight: 600;
							color: #ffffff;
						}
						.time {
							font-size: 24rpx;
							color: #d3d3d3;
						}
					}
				}
			}
		}
	}
}
</style>
